package com.hyz.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hyz.pojo.ResponseResult;
import com.hyz.pojo.User;
import com.hyz.service.AuthenticationService;
import com.hyz.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController
public class LoginController {
    @Autowired
    private UserService userService;

    @Autowired
    private AuthenticationService authenticationService;

    @PostMapping("/login")
    public ResponseResult<Boolean> checkLogin(@RequestParam String userName
            ,  @RequestParam  String password
            ,   @RequestParam Long rightsId) {
//        QueryWrapper<User> wrapper = new QueryWrapper<>();
//        wrapper.lambda().eq(User::getUsername, userName)
//                .eq(User::getPassword, password);
        Boolean loginResult = authenticationService.getLoginResult(userName, password, rightsId);
        if (!loginResult) {
            return new ResponseResult<>(400, "失败", false);
        }else{
            return new ResponseResult<>(200, "成功", true);
        }

    }
}
